package com.example.itcacp.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.itcacp.entity.Like;
import com.example.itcacp.repository.mybatis.LikeMapper;
import com.example.itcacp.service.LikeService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LikeServiceImpl extends ServiceImpl<LikeMapper, Like> implements LikeService {

    @Resource
    private LikeMapper likeMapper;

    /**
     * 添加点赞记录
     * */
    @Override
    public void addLike(Like like) {
        likeMapper.insert ( like );
    }

    /**
     * 分页查询用户点赞的所记录
     * */
    @Override
    public PageInfo<Like> selectUserLikePage(Integer pageNum, Integer pageSize, Long userId) {
        PageHelper.startPage ( pageNum, pageSize );
        List<Like> likesByUserId = likeMapper.getLikesByUserId ( userId );
        return PageInfo.of ( likesByUserId );
    }
}
